using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class EntityHealth :MonoBehaviour, IDamagable
{

    [SerializeField] protected float currentHealth;
    protected bool isDead;
    protected virtual void Awake()
    {

    }
    protected virtual void OnEnable()
    {
        isDead = false;
    }
    public virtual void TakeDamage(float damage, Vector2 hurtDir)
    {
        if (isDead)
            return;
        ReduceHealth(damage, hurtDir);
    }

    public virtual bool ReduceHealth(float damage, Vector2 hurtDir)
    {
        if (currentHealth - damage <= 0)
        {
            currentHealth = 0;
            Dead(hurtDir);
            return false;
        }

        currentHealth -= damage;
        return true;
    }
    
    public virtual void Dead(Vector2 hurtDir)
    {
        isDead = true;
    }
}
